import { $ajax, ajaxGet, ajaxPost, jsonPost, base } from '@/util'
import Vue from 'vue'
import bus from '@/bus'
import clipboard from 'clipboard'

Vue.prototype.$ajax = $ajax
Vue.prototype.$ajaxGet = ajaxGet
Vue.prototype.$ajaxPost = ajaxPost
Vue.prototype.$jsonPost = jsonPost
Vue.prototype.$bus = bus
Vue.prototype.$clipboard = clipboard
Vue.prototype.$base = base
Vue.prototype.$format = (date) => {
  // return !!date ? bus.$moment(date).format('YYYY-MM-DD hh:mm:ss') : null;
  return date ? formatDate(date, true) + ':00' : null
}

Vue.prototype.$cache = {}
Vue.prototype.$back = {}
Vue.prototype.$config = {
  serviceStatusList: [{
    value: 1,
    text: '等待报价'
  }, {
    value: 2,
    text: '报价'
  }, {
    value: 3,
    text: '施工'
  }, {
    value: 4,
    text: '完工'
  }, {
    value: 5,
    text: '已结算'
  }, {
    value: 6,
    text: '服务取消'
  }],
  dateOptions: {
    shortcuts: [{
      text: '最近一周',
      value() {
        const start = new Date()
        const end = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
        return [start, end]
      }
    }, {
      text: '最近一个月',
      value() {
        const start = new Date()
        const end = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
        return [start, end]
      }
    }, {
      text: '最近三个月',
      value() {
        const start = new Date()
        const end = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
        return [start, end]
      }
    }, {
      text: '最近半年',
      value() {
        const start = new Date()
        const end = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 180)
        return [start, end]
      }
    }, {
      text: '最近三年',
      value() {
        const start = new Date()
        const end = new Date()
        start.setFullYear(start.getFullYear() - 3)
        return [start, end]
      }
    }]
  },
  futureDateOptions: {
    shortcuts: [{
      text: '未来一个月',
      value() {
        const start = new Date()
        const end = new Date()
        end.setTime(end.getTime() + 3600 * 1000 * 24 * 30)
        return [start, end]
      }
    }, {
      text: '未来15天',
      value() {
        const start = new Date()
        const end = new Date()
        end.setTime(end.getTime() + 3600 * 1000 * 24 * 15)
        return [start, end]
      }
    }, {
      text: '未来7天',
      value() {
        const start = new Date()
        const end = new Date()
        end.setTime(end.getTime() + 3600 * 1000 * 24 * 7)
        return [start, end]
      }
    }]
  },
  dailyDateOptions: {
    shortcuts: [{
      text: '本周',
      value() {
        const start = new Date()
        const end = new Date()
        const mondayTime = start.getTime() - (start.getDay() - 1) * 24 * 60 * 60 * 1000
        const moday = new Date(mondayTime)
        return [moday, end]
      }
    }, {
      text: '本月',
      value() {
        const start = new Date()
        const end = new Date()
        start.setDate(1)
        return [start, end]
      }
    }]
  },
}